package UnitTest;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Auther: dingitan
 * @Date: 2020/4/16/016 18 53
 * @Description:
 */
public class MapCollectors {


    public static void main(String[] args) {
        List<AreaSale> list = new ArrayList<>();
        list.add(new AreaSale("dingding","120000","120002","120003"));
        list.add(new AreaSale("dddddddd","120000","120004","120005"));
        list.add(new AreaSale("bbbbbbbb","120000","120006","120007"));
        list.add(new AreaSale("cccccccc","120000","120008","120009"));
        list.add(new AreaSale("aaaaaaaa","120000","120010","120011"));
        list.add(new AreaSale("mmmmmmmm","120000","120012","120013"));
        Map<String, Map<String, Map<String, List<AreaSale>>>> map = list.stream().
                collect(Collectors.groupingBy(AreaSale::getProvince,
                        Collectors.groupingBy(AreaSale::getCity, Collectors.groupingBy(AreaSale::getCounty))));
        System.out.println(map);
    }
}
class AreaSale{

    private String name;
    private String province;
    private String city;
    private String county;

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCounty() {
        return county;
    }

    public void setCounty(String county) {
        this.county = county;
    }

    public AreaSale() {
    }

    public AreaSale(String name, String province, String city, String county) {
        this.name = name;
        this.province = province;
        this.city = city;
        this.county = county;
    }
}
